package view;

import java.awt.Color;
import java.awt.Component;

import javax.swing.*;
import javax.swing.border.LineBorder;

import model.Exercise;;

public class ExerciseListRenderer extends JLabel implements ListCellRenderer<Exercise> {
	private static final long serialVersionUID = 1L;

	public ExerciseListRenderer() {
	}

	@Override
	public Component getListCellRendererComponent(JList<? extends Exercise> arg0,
			Exercise value, int index, boolean isSelected, boolean cellHasFocus) {
		Exercise ex = (Exercise)value;
		setText(ex.getName());
		
		if(isSelected){
			setForeground(Color.WHITE);
			setBackground(Color.DARK_GRAY);
			setBorder(new LineBorder(Color.BLACK));
		}else{
			setForeground(Color.BLACK);
			setBackground(Color.WHITE);
			setBorder(null);	
		}
		
		setOpaque(true);
		
		return this;
	}

}
